<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="main-content">
    <div class="box box-main">
        <form id="troubleForm" model="post" action="<c:url value="/web/repair/troubleCat/addOrUpdate.action"/>"
              method="post" class="form-horizontal">
            <div class="box-body">
                <div class="form-unit">基本信息</div>
                <input type="hidden" name="id" value="${troubleCat.id}"/>
                <input type="hidden" name="serial" value="${troubleCat.serial}"/>
                <input type="hidden" name="organizationName" value="${troubleCat.organizationName}"/>
                <input type="hidden" name="classify" value="${troubleCat.classify}"/>
                <input type="hidden" name="major" value="${troubleCat.major}"/>

                <input type="hidden" name="createDate"
                       value="<fmt:formatDate value="${troubleCat.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span>故障名称：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="troubleCatName" name="troubleCatName" value="${troubleCat.troubleCatName}"
                                       class="form-control required">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span>所属部门：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="select_organization" id="select_organization" name="select_organization"
                                       class="form-control required">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 维修分类：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="select_repairClassify" name="select_repairClassify"
                                       id="select_repairClassify"
                                       maxlength="100"
                                       class="form-control required ">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 报修专业：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="select_facilityCat" name="select_facilityCat" id="select_facilityCat"
                                       maxlength="100"
                                       class="form-control required ">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                工分：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="points" name="points" value="${troubleCat.points}"
                                       maxlength="100" class="form-control ">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i>
                            保 存
                        </button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                class="fa fa-times"></i> 关 闭
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $("#troubleForm").validate({
        submitHandler: function (form) {
            if (!validateMagicSuggest({
                select_facilityCat: '不能为空',
                select_repairClassify: '不能为空',
            })) return false;
            js.ajaxSubmitForm($(form), function (data) {
                js.showMessage(data.msg);
                if (data.status == Global.NO) {
                    closeView();
                    $('#troubleDataGrid').dataGrid("refresh");
                }
            }, "json");
        }
    });
    var select_facilityCat = $('#select_facilityCat').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/facilityCat/getFacilityCatListMagic.action?id=${troubleCat.facilityCat.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${troubleCat.facilityCat.id}')
    });
    $(select_facilityCat).on('selectionchange', function(e,m){
        validateMagicReload();
    });
    var select_repairClassify = $('#select_repairClassify').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/dictInfo/getDictInfoListMagic.action?id=${troubleCat.reportClassify.id}&&typeCode=REPAIR_CLASSIFY" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${troubleCat.reportClassify.id}')
    });
    $(select_repairClassify).on('selectionchange', function(e,m){
        validateMagicReload();
    });
    var select_organization = $('#select_organization').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/organization/getOrganizationListMagic.action?id=${troubleCat.organization.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${troubleCat.organization.id}')
    });



    function closeView() {
        layer.close(LayWin['wTroubleCat']);
    }
</script>


